using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.Reflection;
using NalogGarLoader.Data.Tables.GarEntries;
using NalogGarLoader.Data.Tables.GarEntries.AddressTables;
using NalogGarLoader.Data.Tables.GarEntries.ReferenceTables;

namespace NalogGarLoader.Data;
public static class GarTypes
{        
    #region Константы: Справочная информация

    public const string AS_ROOM_TYPES = "AS_ROOM_TYPES";
    public const string AS_PARAM_TYPES = "AS_PARAM_TYPES";
    public const string AS_OPERATION_TYPES = "AS_OPERATION_TYPES";
    public const string AS_OBJECT_LEVELS = "AS_OBJECT_LEVELS";
    public const string AS_NORMATIVE_DOCS_TYPES = "AS_NORMATIVE_DOCS_TYPES";
    public const string AS_NORMATIVE_DOCS_KINDS = "AS_NORMATIVE_DOCS_KINDS";
    public const string AS_HOUSE_TYPES = "AS_HOUSE_TYPES";
    public const string AS_APARTMENT_TYPES = "AS_APARTMENT_TYPES";
    public const string AS_ADDR_OBJ_TYPES = "AS_ADDR_OBJ_TYPES";
    public const string AS_ADDHOUSE_TYPES = "AS_ADDHOUSE_TYPES";

    #endregion

    #region Константы: Основные таблицы
    public const string AS_ADDR_OBJ = "AS_ADDR_OBJ";
    public const string AS_ADDR_OBJ_DIVISION = "AS_ADDR_OBJ_DIVISION";
    public const string AS_ADDR_OBJ_PARAMS = "AS_ADDR_OBJ_PARAMS";
    public const string AS_ADM_HIERARCHY = "AS_ADM_HIERARCHY";
    public const string AS_APARTMENTS = "AS_APARTMENTS";
    public const string AS_APARTMENTS_PARAMS = "AS_APARTMENTS_PARAMS";
    public const string AS_CARPLACES = "AS_CARPLACES";
    public const string AS_CARPLACES_PARAMS = "AS_CARPLACES_PARAMS";
    public const string AS_CHANGE_HISTORY = "AS_CHANGE_HISTORY";
    public const string AS_HOUSES = "AS_HOUSES";
    public const string AS_HOUSES_PARAMS = "AS_HOUSES_PARAMS";
    public const string AS_MUN_HIERARCHY = "AS_MUN_HIERARCHY";
    public const string AS_NORMATIVE_DOCS = "AS_NORMATIVE_DOCS";
    public const string AS_REESTR_OBJECTS = "AS_REESTR_OBJECTS";
    public const string AS_ROOMS = "AS_ROOMS";
    public const string AS_ROOMS_PARAMS = "AS_ROOMS_PARAMS";
    public const string AS_STEADS = "AS_STEADS";
    public const string AS_STEADS_PARAMS = "AS_STEADS_PARAMS";

    #endregion    

    public static ImmutableDictionary<string, Type> GarTypeMapping { get; private set; }
    public static ImmutableHashSet<string> GarTypeSet { get; private set; }

    static GarTypes()
    {
        Dictionary<string, Type> dict = new()
        {
            { GarTypes.AS_ADDHOUSE_TYPES, typeof(AddHouseType)},
            { GarTypes.AS_HOUSE_TYPES, typeof(HouseType)},
            { GarTypes.AS_ADDR_OBJ_TYPES, typeof(AddressObjectType)},
            { GarTypes.AS_APARTMENT_TYPES, typeof(ApartmentType)},
            { GarTypes.AS_NORMATIVE_DOCS_KINDS, typeof(NDocKind)},
            { GarTypes.AS_NORMATIVE_DOCS_TYPES, typeof(NDocType)},
            { GarTypes.AS_OBJECT_LEVELS, typeof(ObjectLevel)},
            { GarTypes.AS_OPERATION_TYPES, typeof(OperationType)},
            { GarTypes.AS_PARAM_TYPES, typeof(ParamType)},
            { GarTypes.AS_ROOM_TYPES, typeof(RoomType)},
            { GarTypes.AS_ADDR_OBJ, typeof(AddressObject)},
            { GarTypes.AS_ADDR_OBJ_DIVISION, typeof(AddressObjectDivision)},
            { GarTypes.AS_ADDR_OBJ_PARAMS, typeof(AddressObjParam)},
            { GarTypes.AS_ADM_HIERARCHY, typeof(AdmHierarchy)},
            { GarTypes.AS_APARTMENTS, typeof(Apartment)},
            { GarTypes.AS_APARTMENTS_PARAMS, typeof(ApartmentParam)},
            { GarTypes.AS_CARPLACES, typeof(CarPlace)},
            { GarTypes.AS_CARPLACES_PARAMS, typeof(CarPlaceParam)},
            { GarTypes.AS_CHANGE_HISTORY, typeof(ChangeHistory)},
            { GarTypes.AS_HOUSES, typeof(House)},
            { GarTypes.AS_HOUSES_PARAMS, typeof(HouseParam)},
            { GarTypes.AS_MUN_HIERARCHY, typeof(MunHierarchy)},
            { GarTypes.AS_NORMATIVE_DOCS, typeof(NormativeDoc)},
            { GarTypes.AS_REESTR_OBJECTS, typeof(ReestrObject)},
            { GarTypes.AS_ROOMS, typeof(Room)},
            { GarTypes.AS_ROOMS_PARAMS, typeof(RoomParam)},
            { GarTypes.AS_STEADS, typeof(Stead)},
            { GarTypes.AS_STEADS_PARAMS, typeof(SteadParam)},
        };

        GarTypes.GarTypeMapping = dict.ToImmutableDictionary();
        GarTypes.GarTypeSet = GarTypes.GarTypeMapping.Keys.ToImmutableHashSet();
    } 
}